package com.chaosj.skill.prometheus

import io.micrometer.core.instrument.Counter
import io.micrometer.core.instrument.Metrics
import io.micrometer.core.instrument.simple.SimpleMeterRegistry

/**
 * @Description:
 * @author caoyangjie
 * @date 2020年01月2020/1/14日 13:58
 * @Copyright: © 赢时胜
 */
class CounterSample {
    static void main(args){
        Counter counter = Counter.builder("counter")
                .tag("counter", "counter")
                .description("counter")
                .register(new SimpleMeterRegistry())
        counter.increment()
        counter.increment(2D)
        System.out.println(counter.count())
        System.out.println(counter.measure())
        //全局静态方法
        Metrics.addRegistry(new SimpleMeterRegistry())
        counter = Metrics.counter("counter", "counter", "counter")
        counter.increment(10086D)
        counter.increment(10087D)
        System.out.println(counter.count())
        System.out.println(counter.measure())
    }
}
